/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MenuPrincipalFrm.java
 *
 * Created on 19-dic-2011, 22:44:09
 */
package saludfamiliar;

import java.awt.Component;
import java.text.DateFormat;
import javax.swing.ImageIcon;
import vista.patologias.GestorVistaPatologiasPnl;
import vista.personas.pacientes.GestorVistaPacientesPnl;
import vista.personas.profesionales.GestorVistaProfesionalDlg;
import vista.personas.profesionales.GestorVistaProfesionalesPnl;


/**
 *
 * @author Raul
 */
public class PantallaPrincipalFrm extends javax.swing.JFrame {

    private GestorPantallaPrincipal gestorPantallaPrincipal;


    /** Creates new form PantallaPrincipalFrm */
    public PantallaPrincipalFrm() {
        initComponents();
        setLocationRelativeTo(null);
        
    }

    public PantallaPrincipalFrm(GestorPantallaPrincipal gestorPantallaPrincipal) {
        this.gestorPantallaPrincipal = gestorPantallaPrincipal;
        initComponents();
        setLocationRelativeTo(null);
    }
    
    public GestorPantallaPrincipal getGestorPantallaPrincipal() {
        return gestorPantallaPrincipal;
    }

    public void setGestorPantallaPrincipal(GestorPantallaPrincipal gestorPantallaPrincipal) {
        this.gestorPantallaPrincipal = gestorPantallaPrincipal;
    }
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabbedPane = new components.JTabbedPaneX();
        inicioPnl = new util.components.GradientPanel();
        administracionBtn = new javax.swing.JButton();
        enfermedadesBtn = new javax.swing.JButton();
        profesionalesBtn = new javax.swing.JButton();
        pacientesBtn = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel1 = new javax.swing.JLabel();
        titlePnl = new util.components.GradientPanel();
        jLabel3 = new javax.swing.JLabel();
        fechaDeHoyTxt = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        archivoMenu = new javax.swing.JMenu();
        salirMnItm = new javax.swing.JMenuItem();
        verMenu = new javax.swing.JMenu();
        panelDeInicioMenu = new javax.swing.JMenuItem();
        reportesMenu = new javax.swing.JMenu();
        reporteProfesionalesMenu = new javax.swing.JMenuItem();
        reportePacientesMenu = new javax.swing.JMenuItem();
        reporteEnfermedadesMenu = new javax.swing.JMenuItem();
        profesionalesMenu = new javax.swing.JMenu();
        nuevoProfesionalMenu = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Salud Familiar");
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));

        tabbedPane.setPreferredSize(new java.awt.Dimension(755, 462));

        inicioPnl.setGradientColor1(new java.awt.Color(242, 241, 240));
        inicioPnl.setGradientColor2(new java.awt.Color(182, 199, 216));

        administracionBtn.setFont(new java.awt.Font("Calibri", 1, 14)); // NOI18N
        administracionBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/tablet_72.png"))); // NOI18N
        administracionBtn.setText("Administración");
        administracionBtn.setBorderPainted(false);
        administracionBtn.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        administracionBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                administracionBtnActionPerformed(evt);
            }
        });

        enfermedadesBtn.setFont(new java.awt.Font("Calibri", 1, 14)); // NOI18N
        enfermedadesBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/pathology_72.png"))); // NOI18N
        enfermedadesBtn.setText("Enfermedades");
        enfermedadesBtn.setBorderPainted(false);
        enfermedadesBtn.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        enfermedadesBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                enfermedadesBtnActionPerformed(evt);
            }
        });

        profesionalesBtn.setFont(new java.awt.Font("Calibri", 1, 14)); // NOI18N
        profesionalesBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/doctor_72.png"))); // NOI18N
        profesionalesBtn.setText("Profesionales");
        profesionalesBtn.setBorderPainted(false);
        profesionalesBtn.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        profesionalesBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                profesionalesBtnActionPerformed(evt);
            }
        });

        pacientesBtn.setFont(new java.awt.Font("Calibri", 1, 14)); // NOI18N
        pacientesBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/patient_72.png"))); // NOI18N
        pacientesBtn.setText("Pacientes");
        pacientesBtn.setBorderPainted(false);
        pacientesBtn.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        pacientesBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pacientesBtnActionPerformed(evt);
            }
        });

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/Clinica.jpg"))); // NOI18N

        titlePnl.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(127, 157, 185)));
        titlePnl.setGradientColor1(java.awt.Color.white);
        titlePnl.setGradientColor2(java.awt.Color.lightGray);

        jLabel3.setFont(new java.awt.Font("Cambria", 1, 36)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(42, 72, 108));
        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/appointment_48.png"))); // NOI18N
        jLabel3.setText("SALUD FAMILIAR");

        DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
        fechaDeHoyTxt.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        fechaDeHoyTxt.setText(df.format(new java.util.Date()));

        javax.swing.GroupLayout titlePnlLayout = new javax.swing.GroupLayout(titlePnl);
        titlePnl.setLayout(titlePnlLayout);
        titlePnlLayout.setHorizontalGroup(
            titlePnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(titlePnlLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(fechaDeHoyTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        titlePnlLayout.setVerticalGroup(
            titlePnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, titlePnlLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(titlePnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(fechaDeHoyTxt))
                .addContainerGap())
        );

        javax.swing.GroupLayout inicioPnlLayout = new javax.swing.GroupLayout(inicioPnl);
        inicioPnl.setLayout(inicioPnlLayout);
        inicioPnlLayout.setHorizontalGroup(
            inicioPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(inicioPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(inicioPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(inicioPnlLayout.createSequentialGroup()
                        .addGroup(inicioPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(administracionBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(enfermedadesBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(profesionalesBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(pacientesBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(124, 124, 124)
                        .addComponent(jLabel1)
                        .addGap(0, 188, Short.MAX_VALUE))
                    .addComponent(titlePnl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        inicioPnlLayout.setVerticalGroup(
            inicioPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(inicioPnlLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titlePnl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24)
                .addGroup(inicioPnlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(inicioPnlLayout.createSequentialGroup()
                        .addComponent(pacientesBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(profesionalesBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(enfermedadesBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(administracionBtn))
                    .addComponent(jSeparator2))
                .addContainerGap())
        );

        tabbedPane.addTab("Inicio", new javax.swing.ImageIcon(getClass().getResource("/resources/house.png")), inicioPnl); // NOI18N

        archivoMenu.setText("Archivo");

        salirMnItm.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        salirMnItm.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/exit_24.png"))); // NOI18N
        salirMnItm.setText("Salir");
        salirMnItm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salirBtnActionPerformed(evt);
            }
        });
        archivoMenu.add(salirMnItm);

        jMenuBar1.add(archivoMenu);

        verMenu.setText("Ver");

        panelDeInicioMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_HOME, java.awt.event.InputEvent.ALT_MASK));
        panelDeInicioMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/house.png"))); // NOI18N
        panelDeInicioMenu.setText("Panel de inicio");
        panelDeInicioMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                panelDeInicioMenuActionPerformed(evt);
            }
        });
        verMenu.add(panelDeInicioMenu);

        jMenuBar1.add(verMenu);

        reportesMenu.setText("Reportes");

        reporteProfesionalesMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/doctor_16.png"))); // NOI18N
        reporteProfesionalesMenu.setText("Profesionales");
        reporteProfesionalesMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reporteProfesionalesMenuActionPerformed(evt);
            }
        });
        reportesMenu.add(reporteProfesionalesMenu);

        reportePacientesMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/patient_16.png"))); // NOI18N
        reportePacientesMenu.setText("Pacientes");
        reportePacientesMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reportePacientesMenuActionPerformed(evt);
            }
        });
        reportesMenu.add(reportePacientesMenu);

        reporteEnfermedadesMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/pathology_16.png"))); // NOI18N
        reporteEnfermedadesMenu.setText("Enfermedades");
        reporteEnfermedadesMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reporteEnfermedadesMenuActionPerformed(evt);
            }
        });
        reportesMenu.add(reporteEnfermedadesMenu);

        jMenuBar1.add(reportesMenu);

        profesionalesMenu.setText("Profesionales");

        nuevoProfesionalMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/add.png"))); // NOI18N
        nuevoProfesionalMenu.setText("Nuevo");
        nuevoProfesionalMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nuevoProfesionalMenuActionPerformed(evt);
            }
        });
        profesionalesMenu.add(nuevoProfesionalMenu);

        jMenuBar1.add(profesionalesMenu);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1116, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void profesionalesBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_profesionalesBtnActionPerformed
        getGestorPantallaPrincipal().abrirTab(GestorPantallaPrincipal.PROFESIONALES);
    }//GEN-LAST:event_profesionalesBtnActionPerformed

    private void administracionBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_administracionBtnActionPerformed
        getGestorPantallaPrincipal().abrirTab(GestorPantallaPrincipal.ADMINISTRACION);
    }//GEN-LAST:event_administracionBtnActionPerformed

    private void salirBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salirBtnActionPerformed
        System.exit(0);
    }//GEN-LAST:event_salirBtnActionPerformed

    private void panelDeInicioMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_panelDeInicioMenuActionPerformed
        agregarTab("Inicio", "/resources/house.png", inicioPnl);
    }//GEN-LAST:event_panelDeInicioMenuActionPerformed

    private void reporteProfesionalesMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reporteProfesionalesMenuActionPerformed
        (new GestorVistaProfesionalesPnl()).listarTodos();
    }//GEN-LAST:event_reporteProfesionalesMenuActionPerformed

    private void nuevoProfesionalMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nuevoProfesionalMenuActionPerformed
        GestorVistaProfesionalDlg gestorEditor = new GestorVistaProfesionalDlg();
        gestorEditor.abrirFormulario();
    }//GEN-LAST:event_nuevoProfesionalMenuActionPerformed

    private void enfermedadesBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enfermedadesBtnActionPerformed
        getGestorPantallaPrincipal().abrirTab(GestorPantallaPrincipal.ENFERMEDADES);
    }//GEN-LAST:event_enfermedadesBtnActionPerformed

    private void pacientesBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pacientesBtnActionPerformed
        getGestorPantallaPrincipal().abrirTab(GestorPantallaPrincipal.PACIENTES);
    }//GEN-LAST:event_pacientesBtnActionPerformed

    private void reportePacientesMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reportePacientesMenuActionPerformed
        (new GestorVistaPacientesPnl()).listarTodos();
    }//GEN-LAST:event_reportePacientesMenuActionPerformed

    private void reporteEnfermedadesMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reporteEnfermedadesMenuActionPerformed
        (new GestorVistaPatologiasPnl()).listarTodos();
    }//GEN-LAST:event_reporteEnfermedadesMenuActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PantallaPrincipalFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PantallaPrincipalFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PantallaPrincipalFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PantallaPrincipalFrm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new PantallaPrincipalFrm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton administracionBtn;
    private javax.swing.JMenu archivoMenu;
    private javax.swing.JButton enfermedadesBtn;
    private javax.swing.JLabel fechaDeHoyTxt;
    private util.components.GradientPanel inicioPnl;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JMenuItem nuevoProfesionalMenu;
    private javax.swing.JButton pacientesBtn;
    private javax.swing.JMenuItem panelDeInicioMenu;
    private javax.swing.JButton profesionalesBtn;
    private javax.swing.JMenu profesionalesMenu;
    private javax.swing.JMenuItem reporteEnfermedadesMenu;
    private javax.swing.JMenuItem reportePacientesMenu;
    private javax.swing.JMenuItem reporteProfesionalesMenu;
    private javax.swing.JMenu reportesMenu;
    private javax.swing.JMenuItem salirMnItm;
    private components.JTabbedPaneX tabbedPane;
    private util.components.GradientPanel titlePnl;
    private javax.swing.JMenu verMenu;
    // End of variables declaration//GEN-END:variables

    /** Agrega una pestania con un <code>panel</code> representada por un <code>titulo</code>
     * y un <code>icono</code>
     * 
     * @param titulo el titulo para esta pestania
     * @param icono la ruta del icono para esta pestania
     * @param panel el panel para esta pestania
     */
    public void agregarTab(String titulo, String icono, Component panel) {
        tabbedPane.addTab(titulo, new ImageIcon(getClass().getResource(icono)), panel);
    }
    
    public void titular(String titulo){
        this.setTitle(titulo);
    }

}
